<template>
  <ul class="tabbar-container">
    <li>
      <router-link to="/bookshelf" @click="switchTab">
        <i
          class="iconfont icon-icon-wodeshujia"
          :style="{ color: $route.meta.num == 0 ? '#404040' : '#aaa' }"
        ></i>
        <span :class="$route.meta.num == 0 ? 'current' : ''">书架</span>
      </router-link>
    </li>
    <li>
      <router-link
        to="/bookcity/recommend"
        @click="switchTab('/bookcity/recommend')"
      >
        <i
          class="iconfont icon-shucheng"
          :style="{ color: $route.meta.num == 1 ? '#404040' : '#aaa' }"
        ></i>
        <span :class="$route.meta.num == 1 ? 'current' : ''">书城</span>
      </router-link>
    </li>
    <li>
      <router-link to="/category/female" @click="switchTab">
        <i
          class="iconfont icon-fenlei"
          :style="{ color: $route.meta.num == 2 ? '#404040' : '#aaa' }"
        ></i>
        <span :class="$route.meta.num == 2 ? 'current' : ''">分类</span>
      </router-link>
    </li>
    <li>
      <router-link to="/user" @click="switchTab">
        <i
          class="iconfont icon-wode"
          :style="{ color: $route.meta.num == 3 ? '#404040' : '#aaa' }"
        ></i>
        <span :class="$route.meta.num == 3 ? 'current' : ''">我的</span>
      </router-link>
    </li>
  </ul>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    switchTab(path) {
      if (path) {
        this.$router.push(path);
      } else {
        this.$router.push(`${$route.meta.path}`);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.tabbar-container {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 60px;
  background-color: #fff;
  display: flex;
  justify-content: space-around;
  font-size: 13px;
  li {
    flex: 1;
    margin-top: 10px;
    a {
      color: #cdcdcd;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .iconfont {
        font-size: 30px;
        margin-bottom: 5px;
      }
      .current {
        color: #404040;
      }
    }
  }
}
</style>